package com.gold.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gold.exception.ServiceException;
import com.gold.model.PurchaseGold;
import com.gold.persist.PurchaseGoldMapper;
import com.gold.service.PurchaseGoldService;
import com.gold.util.Page;

@Service
public class PurchaseGoldServiceImpl implements PurchaseGoldService {
	
	@Resource
	PurchaseGoldMapper purchaseGoldMapper;

	@Override
	public boolean delete(Integer modelPK) throws ServiceException {
		// TODO Auto-generated method stub
		return purchaseGoldMapper.deleteByPrimaryKey(modelPK)>0?true:false;
	}

	@Override
	public boolean save(PurchaseGold model) throws ServiceException {
		// TODO Auto-generated method stub
		return purchaseGoldMapper.insertSelective(model)>0?true:false;
	}

	@Override
	public PurchaseGold load(Integer modelPK) throws ServiceException {
		// TODO Auto-generated method stub
		return purchaseGoldMapper.selectByPrimaryKey(modelPK);
	}

	//huilay 2016年2月21日14:39:45 通过添加查询数据
	@Override
	public Page<Map> findByCondition(Page<Map> page) throws ServiceException {
		// TODO Auto-generated method stub
		page.setResults(purchaseGoldMapper.findByCondition(page));
        page.setTotalRecord(purchaseGoldMapper.findCountByCondition(page));
        return page;
	}

	@Override
	public int countAll() throws ServiceException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean update(PurchaseGold model) throws ServiceException {
		// TODO Auto-generated method stub
		return purchaseGoldMapper.updateByPrimaryKeySelective(model)>0?true:false;
	}

	@Override
	public List<PurchaseGold> findAll() throws ServiceException {
		// TODO Auto-generated method stub
		return purchaseGoldMapper.getAll();
	}
}
